<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>公共文件 - Fnk</title>
</head>
<body>
    <h1 align="center">公共文件</h1><hr/>
    {% if root %}
        <h2>选择上传文件</h2>
        <form method="POST" action="/public_files" enctype="multipart/form-data">
            <input type="file" name="file" required>
            <button type="submit">确定</button>
        </form>
    {% endif %}

    {% with messages = get_flashed_messages(with_categories=true) %}
        {% if messages %}
            {% for category, message in messages %}
                <div style="color:{% if category == 'error' %} red {% else %} green {% endif %}; ">{{ message }}</div>
            {% endfor %}
        {% endif %}
    {% endwith %}

    <h2>文件列表</h2>
    <ul>
        {% for file in files %}
            <li>
                <a href="{{ '/files/public/'+file + '?mode=1' }}" target="_blank">{{ file }}</a>
                {% if root %}
                    <a href="{{ '/files/public/'+file+'?mode=2'}}" onclick="return confirm('确认删除文件')">
                        <button>Delete</button>
                    </a>
                {% endif %}
            </li>
        {% endfor %}
        {% if not files %}
            <h6>无文件</h6>
        {% endif %}
    </ul>

    <br>
    <a href="/">主页</a><br/>
</body>
</html>